<?php
/**
 * Created by PhpStorm.
 * User: ndong
 * Date: 2016-12-13
 * Time: 22:07
 */
if (!defined('__CORE_DIR')) {
    exit("Access Denied");
}
class Ctl_Kujiale_Work extends Ctl {

    public function index($page = 1) {
//        echo '1';
//        exit();
        $filter = $pager = array();
        $pager['page'] = max(intval($page), 1);
        $pager['limit'] = $limit = 50;
//        if ($SO = $this->GP('SO')) {
//            $pager['SO'] = $SO;
//            if ($SO['uid']) {
//                $filter['uid'] = $SO['uid'];
//            }
//            if ($SO['title']) {
//                $filter['title'] = "LIKE:%" . $SO['title'] . "%";
//            }
//            if ($SO['home_id']) {
//                $filter['home_id'] = $SO['home_id'];
//            }
//            if ($SO['company_id']) {
//                $filter['company_id'] = $SO['company_id'];
//            }
//            if (is_numeric($SO['status'])){$filter['status'] = $SO['status'];}
//            if(is_numeric($SO['audit'])){$filter['audit'] = $SO['audit'];}
//        }
//        $uids = array();
//        $filter['closed'] = 0;
//        if(CITY_ID){
//            $filter['city_id'] = CITY_ID;
//        }
        if ($items = K::M('clouddesign/design')->items($filter, null, $page, $limit, $count)) {
        }
        //print_r($items);exit();
        $this->pagedata['items'] = $items;
        $this->tmpl = 'admin:kujiale/work/index.html';
    }

    public function so(){
        $this->tmpl = 'admin:kujiale/work/so.html';
    }

    //推荐
    public function recommend(){
        $clouddesignid = $this->GP('clouddesignid');
        $data = array('recommend_status'=>1);
        $result = K::M('clouddesign/design')->update($clouddesignid, $data);
        //print_r($result);exit();
        if($result){
            $this->err->add('推荐成功');
            $this->err->set_data('forward', '?kujiale/word-index.html');
        }else{
            $this->err->add('推荐失败', 212);
        }
    }

//    public function detail(){
//
//    }
}